import request from '@/utils/request'
import { ref } from 'vue'
import processRichText from "@/utils/processRichText"
export default () => {
	const notices = ref([])
	const notice = ref({})
	const getNotice = async () => {
		let data = await request.get('mini/notice')
		notices.value = data.map(item => {
			return {
				...item,
				opentype: "navigate",
				url: `/subpage/notice/index?id=${item.url}`
			}
		})
	}
	const showNotice = async (id) => {
		let data = await request.get(`mini/notice/${id}`)
		data.content = processRichText(data.content)
		notice.value = data

	}
	return {
		getNotice,
		showNotice,
		notices,
		notice
	}
}